package com.chenfan.mcn.model.base;

import com.baomidou.mybatisplus.annotation.TableField;
import com.chenfan.common.vo.UserVO;
import com.chenfan.mcn.config.UserVoContextHolder;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 * @author wulg
 * @date 2022-02-23
 **/
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class BaseTenantEntity extends BaseSaveEntity{

    /**
     * 租户id
     */
    @TableField(value="tenant_id")
    private Long tenantId;

    @Override
    public void init(){
        super.init();
        UserVO userVO = UserVoContextHolder.getUserVo();
        if(userVO != null){
            this.tenantId = userVO.getTenantId();

        }
    }

    @Override
    public void ignore(){
        super.ignore();
        this.tenantId = null;
    }
}
